<template>
	<view class="content">
		<uni-card :is-shadow="false" padding="10px 0">
			<uni-section :title="project.title" type="line">
				<template v-slot:right><uni-tag @click="onSelect" text="切换" type="warning" :inverted="true" /></template>
			</uni-section>
			<uni-row>
				<uni-col :span="12">
					<view>开工日期:{{project.start_date}}</view>
					<view>施工工期:{{project.duration}}天</view>
				</uni-col>
				<uni-col :span="12">
					<view>完工日期:{{project.end_date}}</view>
					<view>剩余工期:{{project.remainDuration}}天</view>
				</uni-col>
			</uni-row>
		</uni-card>
		
		<uni-card :is-shadow="false">
			<uni-row class="text-center">
				<uni-col :span="6" @click="onLink('schedules/schedules')">
					<img src="https://project-1310548517.cos.ap-shanghai.myqcloud.com/app/schedules.png" alt="">
					<view>进度管理</view>
				</uni-col>
				<uni-col :span="6" @click="onLink('disclosure/disclosure')">
					<img src="https://project-1310548517.cos.ap-shanghai.myqcloud.com/app/disclosure.png" alt="">
					<view>技术管理</view>
				</uni-col>
				<uni-col :span="6" @click="onLink('safe/safe')">
					<img src="https://project-1310548517.cos.ap-shanghai.myqcloud.com/app/safe.png" alt="">
					<view>安全文明</view>
				</uni-col>
				<uni-col :span="6" @click="onLink('quality/quality')">
					<img src="https://project-1310548517.cos.ap-shanghai.myqcloud.com/app/quality.png" alt="">
					<view>质量管理</view>
				</uni-col>
			</uni-row>
		</uni-card>
		
		<uni-card :is-shadow="false" padding="10px 0">
			<uni-section title="进度计划执行情况" type="line">
				<template v-slot:right><uni-tag text="进度完成情况" type="warning" :inverted="true" /></template>
			</uni-section>
		</uni-card>
		
		<uni-card :is-shadow="false" padding="10px 0">
			<uni-section title="进度计划表" type="line"></uni-section>
		</uni-card>
		
		<uni-card :is-shadow="false" padding="10px 0">
			<uni-section title="当日项目完成情况" type="line"></uni-section>
		</uni-card>
		
		<uni-card :is-shadow="false" padding="10px 0">
			<uni-section title="项目部人员完成情况" type="line"></uni-section>
		</uni-card>
		
		<uni-popup ref="popup" background-color="#fff" >
			<view>
				<uni-list :border="false">
					<uni-list-item v-for="item in projectSelect" clickable @click="onSelectProject(item)" showArrow :title="item.title" :rightText="item.id == project.id ? '当前' : ''" />
				</uni-list>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				projectSelect:[],
				project: {id:0,title:'',start_date:'',end_date:''}
			}
		},
		onLoad() {
			let data = uni.getStorageSync('user')
			this.projectSelect = data.projects
			this.project = data.projects[0]
		},
		methods: {
			onSelect(){
				this.$refs.popup.open('top')
			},
			onSelectProject(data){
				uni.setStorageSync('project',data)
				this.project = data
				this.$refs.popup.close()
			},
			onLink(url){
				uni.navigateTo({
					url: '/pages/'+url
				});
			}
		}
	}
</script>

<style>
</style>
